package org.gruposp2p.dnie.server.rest;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gruposp2p.dnie.model.DNIeSignedDocument;
import org.springframework.stereotype.Component;
import org.springframework.context.annotation.Scope;

/**
 *
 * @author jj
 */
@Path(value = "/dnieSignedDocument/{documentId}")
@Component
@Scope("request")
public class DnieSignedDocumentResource {

    private static Logger logger =
            LoggerFactory.getLogger(DnieSignedDocumentResource.class);
    /*
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public DNIeSignedDocument get (
            @PathParam("documentId") Integer documentId) {
        DNIeSignedDocument dnieSignedDocument =
                DnieAppContextListener.getInstance(DNIeSignedDocumentModelService.class)
                .get (documentId);
        return dnieSignedDocument;
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public String post (@PathParam("documentId") int documentId,
            SignedDocument signatureDocument) {
        Integer id = Integer.valueOf(documentId);
        logger.info("signatureDocument.keyInfo.x509Data: " +
                signatureDocument.keyInfo.x509Data);
        return "todoOk";
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public String put (SignedDocument signatureDocument) {
        logger.info("signatureDocument.keyInfo.x509Data: " +
                signatureDocument.keyInfo.x509Data);
        return "todoOk";
    }

    @DELETE
    public Response delete (@PathParam("documentId") Integer documentId) {
        DnieAppContextListener.getInstance(
        		DNIeSignedDocumentModelService.class).delete(documentId);
        return Response.ok().build();
    }

    */
}
